<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数解构</title>
</head>
<body>
    
</body>
<script>
    function add([x,y]){
        return x+y;
    }
    let x=add([1,2]);
    console.log(x);
    function move({x, y} = {}) {
  return [x, y];
}


console.log(({x: 3, y: 8})); // [3, 8]
console.log(move({x: 3})); // [3, 0]
console.log(move({}));
 // [0, 0]
console.log(move()); // [0, 0]
function move({x, y} = { x: 1, y: 1 }) {
  return [x, y];
}
console.log(({x: 3, y: 8})); // [3, 8]
console.log(move({x: 3})); // [3, 0]
console.log(move({}));
 // [0, 0]
console.log(move()); // [0, 0]

</script>
</html>